$(function() {
    $('.ck').click(function(){
        var orderid=$(this).find('.order').val();
        $.post('xq',{orderid:orderid},function(date)
        {
            var date=date.msg;
            var src='';
            $.each(date,function(k,val){
                var k=k+1;
                src += '<tr class="js"><td>'+k+'</td>'+
                    '<td>'+val.g_goodsname+'('+val.format+')'+'</td>'+
                    '<td>'+val.total+'</td>' +
                    '</tr>';
                $('.jt').html(src);
            })
        },'json')
    });
    var index = parent.layer.getFrameIndex(window.name); //获取当前窗体索引
    $('.tj').on('click', function() {
        var orderid = $(this).find('.orderid').val();
        $.post("xg", {orderid: orderid}, function (date) {
            parent.$('.orderid').html(orderid + '<input type="hidden" id="orderid" value="' + orderid + '">');
            var data = date.msg.data;
            var src = '';
            var pay = date.msg.pay;
            parent.$('.num').html(pay.num);
            parent.$('.all').html(pay.all_money);
            parent.$('#vip').val(pay.vip);
            parent.$('.orderid').html('<input class="am-text-right" type="text" value="'+pay.orderid+'" style="background: transparent;border:none;">'+'<input type="hidden" id="orderid" value="' + pay.orderid + '">');
            $.each(data, function (k, val) {
                var k=k+1;
                src += '<dl class="am-padding-top-xs am-padding-bottom-xs am-padding-left-sm ">' +
                    '<dt class="dt-h font-z">' +
                    k+
                    val.g_goodsname + '(' + val.format + ')' +
                    '</dt>'+
                    '<div class="am-input-group am-fr">'+
                    '<span class="am-input-group-label minus" onclick="javascript:minus(this)">-'+
                    '</span>'+
                    '<input type="hidden"  class="am-form-field detail_id" value="'+
                    val.id+
                    '">'+
                    '<input type="hidden"  class="am-form-field stemeals" value="'+
                    val.stemeal+
                    '">'+
                    '<input type="hidden"  class="am-form-field nature" value="'+
                    val.nature+
                    '">'+
                    '<input type="text" readonly="readonly" class="am-form-field" value="'+
                    val.count+
                    '">'+
                    '<span class="am-input-group-label add" onclick="javascript:add(this)">+'+
                    '</span>'+
                    '</div>'+
                    '<input type="hidden"  class="am-form-field ordid" value="'+
                    val.orderid+
                    '">'+
                    '<dd>'+
                    '<div class="am-u-md-6 am-u-lg-6 am-padding-left-0 left-w ">'+
                    '<input type="hidden"  class="am-form-field detail_id" value="'+
                    val.id+
                    '">'+
                    '<div class="am-link-muted am-text-xs font-z">单价：￥'+
                    val.money +
                    '</div>'+
                    '<div class="am-text-danger am-text-xs font-z ">小计：￥<span class="ipt1" style="display: inline;cursor:pointer;color:green;">'+
                    val.total +'</span>'+
                    '<input class="ipt2" style="display:none;width:100%;border:1px solid red;width:100px;" maxlength="10"/><input class="ipt3" type="hidden" value="'+val.total+'"/>'+
                    '</div>'+
                    '</div>'+
                    '<div class="am-u-md-6 am-u-lg-6 am-padding-right-0">'+
                    '</div>'+
                    '<div class="clear"></div>'+
                    '<div class="am-u-md-6 am-u-lg-6 am-padding-left-0 left-w ss">'+
                    '<div class="flo-l font-z wendu">'+
                    '<input type="hidden"  class="am-form-field detail_id" value="'+
                    val.id+
                    '">'+
                    '<input type="hidden"  class="am-form-field goodid" value="'+
                    val.goodsid+
                    '">'+
                    '<a class="am-btn am-btn-warning am-radius am-margin-right-sm nature" herf="#">口味('+
                    val.naturename+
                    ')</a>'+
                    '<a class="am-btn am-btn-warning am-radius am-margin-right-sm edit" herf="#">改价'+
                    '</a>'+
                    '</div>'+
                    '</div>'+
                    '</dd>' +
                    '</dl>'
                parent.$('#cart').html(src);
            });
            parent.layer.close(index); //执行关闭
            //window.location.href = "menu?orderid="+orderid;
        });
    })
})